Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched from ip to tz for geolocation #13636

Merged
merged 4 commits into from
Mar 4, 2024
Merged

Conversation

samhotep
Copy link
Member

@samhotep samhotep commented Mar 1, 2024

Done

  • Switched from using ip address for geolocation to using timezone

QA

Issue / Card

Fixes WD-1173

Screenshots

image

Help

QA steps - Commit guidelines

Follow up

Should we also auto-fill the country input?

@webteam-app
Copy link

Demo starting at https://ubuntu-com-13636.demos.haus

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 74.43%. Comparing base (659ab8d) to head (31da434).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13636      +/-   ##
==========================================
- Coverage   74.46%   74.43%   -0.03%     
==========================================
  Files         107      107              
  Lines        2847     2848       +1     
  Branches      948      948              
==========================================
  Hits         2120     2120              
- Misses        703      704       +1     
  Partials       24       24              
Files Coverage Δ
static/js/src/intlTelInput.js 81.39% <0.00%> (-1.94%) ⬇️

webapp/views.py Show resolved Hide resolved
@samhotep samhotep requested a review from carkod March 1, 2024 13:53
Copy link
Contributor

@carkod carkod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for your example with telephone numbers, but because /user-country.json needs the query arg, this is breaking takeovers geolocation

fetchUserCountry.open("GET", "/user-country.json", true);

You may need to do the Intl.DateTimeFormat().resolvedOptions().timeZone; for takeovers too

webapp/app.py Outdated
@@ -628,7 +628,7 @@ def takeovers_index():
core_services_guide.init_app(app)


app.add_url_rule("/user-country.json", view_func=get_user_country_by_ip)
app.add_url_rule("/user-country.json", view_func=get_user_country_by_tz)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are replacing this completely, then you might as well delete get_user_country_by_ip function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but will do separately when updating the takeovers as well

@@ -1071,6 +1072,27 @@ def thank_you():
)


def get_user_country_by_tz():
Copy link
Contributor

@carkod carkod Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also write a comment here for this function explaining how it works? I guess the key of this system is to use Intl.DateTimeFormat().resolvedOptions().timeZone;

I'd also write a Python test. This would not only test that nothing breaks in subsequent changes, but also as an example of how it works.

@carkod
Copy link
Contributor

carkod commented Mar 4, 2024

Also can you remove his Keyerror, this was put there to check which IPs are not detected, which is not needed anymore with this PR.

@samhotep samhotep requested a review from carkod March 4, 2024 13:41
Copy link
Contributor

@carkod carkod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@samhotep samhotep merged commit 76ef96e into main Mar 4, 2024
25 of 27 checks passed
@samhotep samhotep deleted the use-tz-for-geolocation branch March 4, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants